#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    char ch[1002][1002];
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 1; j < m + 1; j++)
        {
            scanf(" %c", &ch[i][j]);
        }
        getchar();
    }
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 1; j < m + 1; j++)
        {
            if (ch[i][j] == '*')
            {
                printf("%c", ch[i][j]);
            }
            else if (ch[i][j] != '*')
            {
                int sum = 0;
                for (int a = -1; a <= 1; a++)
                {
                    for (int b = -1; b <= 1; b++)
                    {
                        if (ch[i + a][j + b] == '*')
                        {
                            sum++;
                        }
                    }
                }
                printf("%d", sum);
            }
        }
        printf("\n");
    }
    return 0;
}